#! /usr/bin/env python
# -*- coding: utf-8 -*-
from uiautomator import AutomatorDevice
from uiautomator import Adb as adb
from GameYYS.YYS import YYS
from CommonLib.Phonedev import CommonAction
DEBUG = True

def printD(str):
	if DEBUG:
		print str

def finddevices():
	d = adb()
	rst=d.devices()
	return rst.keys()


def encoFindAndStartGame(device,adbdev,GameName):
	if GameName == "阴阳师":
		yys=YYS(device,adbdev)
		yys.startGame()


def CreatNewAcount(device,adbdev,GameName):
	if GameName == "阴阳师":
		yys = YYS(device,adbdev)
		yys.CreatNewAcount()

def LogInGame(device,adbdev,GameName):
	if GameName == "阴阳师":
		yys = YYS(device,adbdev)
		yys.LogInGame()




#press home key
if __name__ =='__main__':
	Devlist = finddevices()
	for seri in Devlist:
		phone = AutomatorDevice(serial=seri)
		adbdev = adb(serial=seri)
		ComAct = CommonAction()
		printD(seri)
		FindAndStartGame(phone,adbdev,"阴阳师")
		# LogInGame(phone ,adbdev ,"阴阳师")
		ComAct.updatelcd_sock()